﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;

namespace KhoBanHang
{
    public partial class TongHopMuaHang : Form
    {
        public TongHopMuaHang()
        {
            InitializeComponent();
        }

        private void TongHopMuaHang_Load(object sender, EventArgs e)
        {
            dateTimePicker1.CustomFormat = "dd/MM/yyyy";
            dateTimePicker2.CustomFormat = "dd/MM/yyyy";
        }

        private void btnXem_Click(object sender, EventArgs e)
        {
            DateTime tungay = dateTimePicker1.Value;
            DateTime denngay = dateTimePicker2.Value;

            QLKD_KhoaLuanDataSet.TongHopMuaHangDataTable dt_mua = new QLKD_KhoaLuanDataSet.TongHopMuaHangDataTable();
            QLKD_KhoaLuanDataSetTableAdapters.THMuaHangTableAdapter ada_mua = new KhoBanHang.QLKD_KhoaLuanDataSetTableAdapters.THMuaHangTableAdapter();
            ada_mua.Fill(dt_mua, tungay, denngay);

            ReportDataSource rds = new ReportDataSource("QLKD_KhoaLuanDataSet_TongHopMuaHang", dt_mua);
            
            reportViewer1.LocalReport.DataSources.Clear();
            reportViewer1.LocalReport.DataSources.Add(rds);

            List<ReportParameter> listBien = new List<ReportParameter>();
            ReportParameter bien1 = new ReportParameter("tungay", dateTimePicker1.Value.ToString("dd/MM/yyyy"));
            listBien.Add(bien1);
            ReportParameter bien2 = new ReportParameter("denngay", dateTimePicker2.Value.ToString("dd/MM/yyyy"));
            listBien.Add(bien2);
            reportViewer1.LocalReport.SetParameters(listBien);

            this.reportViewer1.RefreshReport();
            reportViewer1.Visible = true;
        }
    }
}
